<?php
namespace Home\Controller;

use Think\Controller;
use Base\FrontController;

class TestController extends FrontController {

	function _initialize(){
	    $this->thirdAppid=C('third_app_id');
	    $this->thirdAppsecret=C('third_app_secret');
	    $this->appid=C('appid');
	    $this->scope = C('scope');
	    // $this->sdk = new \Home\ORG\WeixinThirdSDK($this->thirdAppid,$this->thirdAppsecret);
	}

	public function getAuthorizeToken(){		
		try {
			    $m=D('Home/AuthorizationInfo');
		    	$re=$m->getAuthorizerAccessToken($this->appid);
		        dump($re);
		        exit;
		} catch (\Exception $e) {
			//$this->ajaxReturn('', $e->getMessage(), '400');
			dump($e);
		}
	}

	public function index(){
		// dump($_REQUEST);
		// dump($GLOBALS);
		$this->customReturn(1,'接口调用成功');
		// dump(111);
	}

	//测试往日历表里插入整月数据
	public function testInsertCalendar(){
		$year=2017;
		$month=6;
		$uid=1;
		for ($day=1; $day<=30 ; $day++) { 
			$c=array();
			$c['uid']=$uid;
			$c['year']=$year;
			$c['month']=$month;
			$c['day']=$day;
			$c['look_id']=$day;
			$c['memo']=sprintf("%d年%d月%d日造型%d",$year,$month,$day,$day);
			$c['create_time']=time();
			$c['status']=1;
			$c['is_top']=(($day%2)==0)?1:0;
			M('bh_calendar')->add($c);
		}
	}	 

	//测试往造型表里插入整月数据
	public function testInsertLooks(){

		$uid=1;
		$label=33;
		$img=1;
		$item_ids="1,2,3";
		for ($day=1; $day<=30 ; $day++) { 
			$c=array();
			$c['uid']=$uid;
			$c['label']=$label;
			$c['img']=$img;
			$c['item_ids']=$item_ids;
			
			$c['create_time']=time();
			$c['status']=1;
			$c['name']=sprintf("造型%d名称",$day);
			$c['memo']=sprintf("造型%d的memo",$day);
			M('bh_looks')->add($c);
		}
	}	 

	
}